From: Lars Ingebrigtsen Date: Sun, 23 Jan 2022 14:43:19 +0000 (+0100) Subject: Allow using outline minor mode in `M-x apropos-value' X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~16^2~3271 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=d0f3de72b678608677e1021f3e3c4dd42935b537;p=emacs.git Allow using outline minor mode in `M-x apropos-value' * lisp/apropos.el (apropos-mode): Set up outline minor mode (bug#31094). (apropos-value): Don't add "---" separators, because it doesn't really seem to add anything much. (apropos-value-internal): Escape newlines so that no values can be confused for headings. --- diff --git a/lisp/apropos.el b/lisp/apropos.el index f47e70ce5cb..a98f2328ac2 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -493,7 +493,12 @@ Intended as a value for `revert-buffer-function'." \\{apropos-mode-map}" (make-local-variable 'apropos--current) - (setq-local revert-buffer-function #'apropos--revert-buffer)) + (setq-local revert-buffer-function #'apropos--revert-buffer) + (setq-local outline-regexp "^[^ \n]+" + outline-level (lambda () 1) + outline-minor-mode-cycle t + outline-minor-mode-highlight t + outline-minor-mode-use-buttons t)) (defvar apropos-multi-type t "If non-nil, this apropos query concerns multiple types. @@ -846,7 +851,7 @@ Returns list of symbols and values found." f v p) apropos-accumulator)))))) (let ((apropos-multi-type do-all)) - (apropos-print nil "\n----------------\n"))) + (apropos-print nil "\n"))) ;;;###autoload (defun apropos-local-value (pattern &optional buffer) @@ -940,13 +945,14 @@ Returns list of symbols and documentation found." (defun apropos-value-internal (predicate symbol function) (when (funcall predicate symbol) - (setq symbol (prin1-to-string - (if (memq symbol '(command-history minibuffer-history)) - ;; The value we're looking for will always be in - ;; the first element of these two lists, so skip - ;; that value. - (cdr (funcall function symbol)) - (funcall function symbol)))) + (let ((print-escape-newlines t)) + (setq symbol (prin1-to-string + (if (memq symbol '(command-history minibuffer-history)) + ;; The value we're looking for will always be in + ;; the first element of these two lists, so skip + ;; that value. + (cdr (funcall function symbol)) + (funcall function symbol))))) (when (string-match apropos-regexp symbol) (if apropos-match-face (put-text-property (match-beginning 0) (match-end 0) @@ -1156,13 +1162,15 @@ as a heading." (old-buffer (current-buffer)) (inhibit-read-only t) (button-end 0) + (first t) symbol item) (set-buffer standard-output) (apropos-mode) (apropos--preamble text) (dolist (apropos-item p) - (when (and spacing (not (bobp))) - (princ spacing)) + (if (and spacing (not first)) + (princ spacing) + (setq first nil)) (setq symbol (car apropos-item)) ;; Insert dummy score element for backwards compatibility with 21.x ;; apropos-item format.